package Week6.J0523;
// bfs

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class kotori和迷宫_xv {
    static int[] dx = {0, 0, 1, -1};
    static int[] dy = {1, -1, 0, 0};
    static int n, m, x1, y1;
    static int N = 35;
    static char[][] arr = new char[N][N];
    static int[][] dist = new int[N][N];

    private static void bfs() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dist[i][j] = -1;
            }
        }

        Queue<int[]> q = new LinkedList<>();
        q.add(new int[]{x1, y1});
        dist[x1][y1] = 0;

        while (!q.isEmpty()) {
            int[] tmp = q.poll();
            int a = tmp[0], b = tmp[1];
            for (int k = 0; k < 4; k++) {
                int x = a + dx[k], y = b + dy[k];
                if (x >= 0 && x < n && y >= 0 && y < m && arr[x][y] != '*' && dist[x][y] == -1) {
                    dist[x][y] = dist[a][b] + 1;
                    if (arr[x][y] != 'e') {
                        q.add(new int[]{x, y});
                    }
                }
            }
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            char[] s = scanner.next().toCharArray();
            for (int j = 0; j < m; j++) {
                arr[i][j] = s[j];
                if (arr[i][j] == 'k') {
                    x1 = i;
                    y1 = j;
                }
            }
        }
        bfs();

        // 更新结果
        int count = 0, ret = 1000;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (arr[i][j] == 'e' && dist[i][j] != -1) {
                    count++;
                    ret = Math.min(ret, dist[i][j]);
                }
            }
        }

        if (count == 0) System.out.println(-1);
        else System.out.println(count + " " + ret);
    }
}
